<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script  >
function check()
{
	
	var c1,c2,c3,c4,c5,c6,c7;
	
	c1= document.f1.pas.value;
    c2= document.f1.newp.value;
    if(c1.length==0)
    {
    	alert("Enter password");
    	
       document.f1.pas.focus();
        return false;
  	 }
    if(c2.length==0)
    {
    	alert("Enter password to confirm");
    	
       document.f1.newp.focus();
        return false;
  	 }
    
    if(c1!=c2)
    {
		alert("Password mismatch... Enter password again");
		document.f1.newp.value="";
        document.f1.newp.focus();
         return false;
    	
    }
    
    c3=document.f1.pann.value;
    var PAN_REGEX= "^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}$";
   
    if(!c3.match(PAN_REGEX))
    {
   	 alert("Please Enter PAN Number in right format. For ex- AAAAA1111A");
   	document.f1.pann.value="";
    document.f1.pann.focus();
   	 return false;
    }
	
    c4=window.content.pann1;
    c5=window.top.pass1;
   // c3=document.f1.pann.value;
    c7=document.f1.oldp.value;
    
    if(c3.length==0)
    {
    	alert("Enter Pan number");
    	
       document.f1.pann.focus();
        return false;
  	 }
    if(c7.length==0)
    {
    	alert("Enter Old password");
    	
       document.f1.oldp.focus();
        return false;
  	 } 
    
    if(c4!=c3)
    	{
    	alert("PAN number mismatch... Enter PAN number again");
		document.f1.pann.value="";
        document.f1.pann.focus();
         return false;	
    	}
    
    if(c5!=c7)
	{
	alert("Password mismatch... Enter Old Password again");
	document.f1.oldp.value="";
    document.f1.oldp.focus();
     return false;	
	}
}
 </script>

</head>
<body>
<form name="f1" action="ChangePasswordServlet" ONSUBMIT="return check()">
<table align="center">
<tr>
<td>Enter PAN number</td>
<td><input type="text" name="pann"/></td>
</tr>
<tr>
<td>Enter Old Password</td>
<td><input type="password" name="oldp"/></td>
</tr>
<tr>
<td>Enter New Password</td>
<td><input type="password" name="pas"/></td>
</tr>
<tr>
<td>Re-enter Password</td>
<td><input type="password" name="newp"/></td>
</tr>
<tr>

<td><input type="submit" value="Submit"  /></td>
</tr>
</table>
</form>
</body>
</html>